import { ConfigDB } from "./config/ConfigDB";
import { StoragerManager } from "./core/managers/StoragerManager";
import { TableName } from "./enum/TableName";

const { ccclass } = cc._decorator;
@ccclass
export default class GameStart extends cc.Component {
    onLoad() {
        StoragerManager.init();
    }
    async start() {
        ConfigDB.load(await this.loadConfig())
    }

    private async loadConfig() {
        return new Promise((resolve, reject) => {
            cc.resources.load(`confs/${TableName.worldConfig}`, cc.JsonAsset, (err, jsonAsset: cc.JsonAsset) => {
                if (err) {
                    reject(err);
                }
                resolve(jsonAsset.json)
            });
        })
    }
}